<template>


  <el-container class="right-panel-container">
    <SettingDialog v-model="showSettings" />
    <!-- 顶部导航栏 -->
    <el-header class="nav-toolbar">
      <div class="header-content">
        <div class="logo-section">
          <el-icon class="logo-icon" size="24">
            <ChatRound />
          </el-icon>
          <h1 class="panel-title">AI对话助手</h1>
        </div>

        <!-- 右侧操作按钮 -->
        <div class="action-buttons">
          <el-button
              class="custom-btn"
              size="small"
              @click="showHistory = !showHistory"
          >
            <Clock class="icon" />
            <span class="btn-text">历史</span>
          </el-button>

          <el-button
              class="custom-btn"
              size="small"
              @click="showSettings = true"
          >
            <Setting class="icon" />
            <span class="btn-text">对话设置</span>
          </el-button>
        </div>
      </div>
    </el-header>

    <!-- 主内容区 - 整体上移 -->
    <el-main class="main-content">
      <div class="content-wrapper">
        <div class="dialogue-container">
          <AIDialogue />
        </div>
        <div
            class="history-sidebar"
            :class="{ 'show-sidebar': showHistory }"
        >
          <h3>对话历史</h3>
          <div class="history-list">
            <div class="history-item active">当前对话</div>
            <div class="history-item">昨天 14:30</div>
            <div class="history-item">昨天 10:15</div>
            <div class="history-item">前天 16:42</div>
          </div>
        </div>
      </div>
    </el-main>
  </el-container>
</template>

<script setup>
import { ref } from 'vue';
import AIDialogue from "@/views/AIDialogue.vue";
import { ChatRound, Setting, Clock } from '@element-plus/icons-vue';
import SettingDialog from "@/components/SettingDialog.vue";

// 状态管理
const showSettings = ref(false);
const showHistory = ref(false);

</script>

<style scoped>
.right-panel-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 防止整体溢出 */
}

.nav-toolbar {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  z-index: 10;
  /* 确保导航栏在顶部，不占用额外空间 */
  margin: 0;
  border: none;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.logo-icon {
  color: #409eff;
  transition: transform 0.3s ease, color 0.3s ease;
}

.logo-section:hover .logo-icon {
  transform: scale(1.1) rotate(5deg);
  color: #6aa8ff;
}

.panel-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  background: linear-gradient(90deg, #409eff, #67c23a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.custom-btn {
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #f5f7fa;
  border-color: #e4e7ed;
  color: #606266;
}

.custom-btn:hover {
  background-color: #eef2f7;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: #dcdfe6;
}

.custom-btn .icon {
  width: 16px;
  height: 16px;
}

.btn-text {
  transition: opacity 0.2s ease;
}

/* 主内容区 - 关键调整：减少顶部间距让内容上移 */
.main-content {
  flex: 1;
  padding: 0; /* 移除默认内边距 */
  margin: 0; /* 移除默认外边距 */
  background-color: #f7f8fa;
  overflow-y: auto;
  /* 确保内容从导航栏正下方开始 */
  position: relative;
  top: 0;
}

.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  height: 100%;
  display: flex;
  padding: 0; /* 移除 wrapper 的内边距 */
}

/* 历史记录侧边栏 */
.history-sidebar {
  width: 0;
  background-color: #ffffff;
  border-right: 1px solid #e5e7eb;
  transition: width 0.3s ease;
  overflow: hidden;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
  flex-shrink: 0;
}

.history-sidebar.show-sidebar {
  width: 280px;
  padding: 20px 0;
}

.history-sidebar h3 {
  padding: 0 20px 15px;
  margin: 0;
  font-size: 16px;
  color: #303133;
  border-bottom: 1px solid #e5e7eb;
}

.history-list {
  margin-top: 15px;
}

.history-item {
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #606266;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover {
  background-color: #f5f7fa;
  color: #409eff;
}

.history-item.active {
  background-color: #eef5ff;
  color: #409eff;
  font-weight: 500;
}

/* 主对话容器 - 核心调整：减少顶部间距实现上移 */
.dialogue-container {
  flex: 1;
  padding: 6px 24px 24px; /* 减少顶部内边距，保持底部空间 */
  min-width: 0;
  margin-top: 0;
}

/* 滚动条美化 */
.main-content::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
  background-color: rgba(156, 163, 175, 0.5);
  border-radius: 3px;
  transition: background-color 0.3s ease;
}

.main-content::-webkit-scrollbar-thumb:hover {
  background-color: rgba(156, 163, 175, 0.8);
}

/* 响应式优化 */
@media (max-width: 768px) {
  .nav-toolbar {
    padding: 0 16px;
  }

  .panel-title {
    font-size: 16px;
  }

  .dialogue-container {
    padding: 12px 16px 16px; /* 移动端进一步减少顶部间距 */
  }
  .history-sidebar.show-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: 260px;
  }
}
</style>
